Added 'all' option to position filter
authorparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 8 Mar 2004 17:46:38 +0000 (17:46 +0000)
committerparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 8 Mar 2004 17:46:38 +0000 (17:46 +0000)
gpsbabel/README
gpsbabel/position.c

index 5f47e9ce51365bef96548ec472a1220b6f0f9f97..84cea124f42707fd74850e767c6172edef2325d4 100644 (file)
@@ -543,6 +543,8 @@ DATA FILTERS
        would remove multiple points that are within 1 foot of each other,
        leaving just one.
 
+       You can also specify the "all" option, which would remove all 
+       of the points rather than leaving one.
 
     RADIUS
 
index f1100bcfa3f0ef55dd6d868c99183b0444ed938c..e5273ed2e3f8a71c3f3bbcbd0d754b8d7ea5b0ab 100644 (file)
@@ -29,6 +29,7 @@ extern queue waypt_head;
 
 static double pos_dist;
 static char *distopt;
+static char *purge_duplicates = NULL;
 static char *latopt;
 static char *lonopt;
 static char *exclopt;
@@ -44,6 +45,7 @@ static
 arglist_t position_args[] = {
        {"distance", &distopt, "Maximum positional distance",
                ARGTYPE_FLOAT | ARGTYPE_REQUIRED },
+       {"all", &purge_duplicates, "Suppress all points close to other points", ARGTYPE_BOOL }, 
        {0, 0, 0, 0}
 };
 
@@ -125,6 +127,7 @@ position_process(void)
        waypoint ** comp;
        double dist;
        int i, wc;
+       int del = 0;
 
        wc = waypt_count();
 
@@ -151,7 +154,17 @@ position_process(void)
                if (dist <= pos_dist) {
                        waypt_del(comp[i]);
                        waypt_free(comp[i]);
+                       del = !!purge_duplicates;
                }
+               else if (del ) {
+                       waypt_del(comp[i]);
+                       waypt_free(comp[i]);
+                       del = 0;
+               }
+       }
+       if ( del ) {
+               waypt_del(comp[wc-1]);
+               waypt_free(comp[wc-1]);
        }
 
        if (comp)